<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
	<meta charset="UTF-8">
	<link rel="shortcut icon" href="favicon.ico">
	<link rel="stylesheet" href="css/iconfont.css">
	<link rel="stylesheet" href="css/global.css">
	<link rel="stylesheet" href="css/bootstrap.min.css">
	<link rel="stylesheet" href="css/bootstrap-theme.min.css">
	<link rel="stylesheet" href="css/swiper.min.css">
	<link rel="stylesheet" href="css/styles.css">
	<link rel="stylesheet" href="css/logo.css" />
	<script src="js/jquery.1.12.4.min.js" charset="UTF-8"></script>
	<script src="js/bootstrap.min.js" charset="UTF-8"></script>
	<script src="js/swiper.min.js" charset="UTF-8"></script>
	<script src="js/global.js" charset="UTF-8"></script>
	<script src="js/jquery.DJMask.2.1.1.js" charset="UTF-8"></script>
	<title>XXX</title>
</head>
<body>
	<!-- 顶部tab -->
	<div id="tbb">
	
	</div>
	<!-- 顶部标题 -->
	<div class="bgf5 clearfix">
		<div class="top-user">
			<div class="inner">
				<a class="logo" href="index.html"> <li id="logo"></li> </a>
				<div class="title">加入购物车</div>
			</div>
		</div>
	</div>
	<div class="content clearfix bgf5">
		<section class="user-center inner clearfix">
			<div class="user-content__box clearfix bgf">
				<div class="title">加入购物车 </div>
				
				<form action="" class="shopcart-form__box">
					
					<div class="shop-title">商品信息</div>
					<div class="shop-order__detail">
						<table class="table">
							<thead>
								<tr>
									<th width="120"></th>
									<th width="300">商品信息</th>
									<th width="150">单价</th>
									<th width="200">数量</th>
									<th width="200">运费</th>
									<th width="80">总价</th>
								</tr>
							</thead>
							<tbody id="tbody">
								
							</tbody>
						</table>
					</div>
					<div class="shop-cart__info clearfix">
						<!--<div class="pull-left text-left">
							<div class="info-line text-nowrap">购买时间：<span class="c6">2017年09月14日 17:31:05</span></div>
							<div class="info-line text-nowrap">交易类型：<span class="c6">担保交易</span></div>
							<div class="info-line text-nowrap">交易号：<span class="c6">1001001830267490496</span></div>
						</div>-->
						<div class="pull-right text-right">
							
							<script>
								$('#coupon').bind('change',function() {
									console.log($(this).val());
								})
							</script>
						</div>
					</div>
					
					
					<div class="user-form-group shopcart-submit">
						<button type="submit" class="btn">加入购物车<button>
					</div>
					<script>
						$(document).ready(function(){
							$(this).on('change','input',function() {
								$(this).parents('.radio-box').addClass('active').siblings().removeClass('active');
							})
						});
					</script>
				</form>
			</div>
		</section>
	</div>
	<!-- 右侧菜单 -->
	<div class="right-nav">
		<ul class="r-with-gotop">
			<li class="r-toolbar-item">
				<a href="udai_welcome.html" class="r-item-hd">
					<i class="iconfont icon-user" data-badge="0"></i>
					<div class="r-tip__box"><span class="r-tip-text">用户中心</span></div>
				</a>
			</li>
			<li class="r-toolbar-item">
				<a href="udai_shopcart.html" class="r-item-hd">
					<i class="iconfont icon-cart"></i>
					<div class="r-tip__box"><span class="r-tip-text">购物车</span></div>
				</a>
			</li>
			<li class="r-toolbar-item">
				<a href="udai_collection.html" class="r-item-hd">
					<i class="iconfont icon-aixin"></i>
					<div class="r-tip__box"><span class="r-tip-text">我的收藏</span></div>
				</a>
			</li>
			<li class="r-toolbar-item">
				<a href="" class="r-item-hd">
					<i class="iconfont icon-liaotian"></i>
					<div class="r-tip__box"><span class="r-tip-text">联系客服</span></div>
				</a>
			</li>
			<li class="r-toolbar-item">
				<a href="issues.html" class="r-item-hd">
					<i class="iconfont icon-liuyan"></i>
					<div class="r-tip__box"><span class="r-tip-text">留言反馈</span></div>
				</a>
			</li>
			<li class="r-toolbar-item to-top">
				<i class="iconfont icon-top"></i>
				<div class="r-tip__box"><span class="r-tip-text">返回顶部</span></div>
			</li>
		</ul>
		<script>
			$(document).ready(function(){ $('.to-top').toTop({position:false}) });
		</script>
	</div>
	<!-- 底部信息 -->
	<div class="footer">
		<div class="footer-tags">
			<div class="tags-box inner">
				<div class="tag-div">
					<img src="images/icons/footer_1.gif" alt="厂家直供">
				</div>
				<div class="tag-div">
					<img src="images/icons/footer_2.gif" alt="一件代发">
				</div>
				<div class="tag-div">
					<img src="images/icons/footer_3.gif" alt="美工活动支持">
				</div>
				<div class="tag-div">
					<img src="images/icons/footer_4.gif" alt="信誉认证">
				</div>
			</div>
		</div>
		<div class="footer-links inner">
			<dl>
				<dt>XXX</dt>
				<a href="temp_article/udai_article10.html"><dd>企业简介</dd></a>
				<a href="temp_article/udai_article11.html"><dd>加入U袋</dd></a>
				<a href="temp_article/udai_article12.html"><dd>隐私说明</dd></a>
			</dl>
			<dl>
				<dt>服务中心</dt>
				<a href="temp_article/udai_article1.html"><dd>售后服务</dd></a>
				<a href="temp_article/udai_article2.html"><dd>配送服务</dd></a>
				<a href="temp_article/udai_article3.html"><dd>用户协议</dd></a>
				<a href="temp_article/udai_article4.html"><dd>常见问题</dd></a>
			</dl>
			<dl>
				<dt>新手上路</dt>
				<a href="temp_article/udai_article5.html"><dd>如何成为代理商</dd></a>
				<a href="temp_article/udai_article6.html"><dd>代销商上架教程</dd></a>
				<a href="temp_article/udai_article7.html"><dd>分销商常见问题</dd></a>
				<a href="temp_article/udai_article8.html"><dd>付款账户</dd></a>
			</dl>
		</div>
		<div class="copy-box clearfix">
			<ul class="copy-links">
				<a href="agent_level.html"><li>网店代销</li></a>
				<a href="class_room.html"><li>U袋学堂</li></a>
				<a href="udai_about.html"><li>联系我们</li></a>
				<a href="temp_article/udai_article10.html"><li>企业简介</li></a>
				<a href="temp_article/udai_article5.html"><li>新手上路</li></a>
			</ul>
			<!-- 版权 -->
			<p class="copyright">
				© 2005-2017 XXX 版权所有，并保留所有权利<br>
				ICP备案证书号：闽ICP备XXX号-2&nbsp;&nbsp;&nbsp;&nbsp;福建省宁德市XXX&nbsp;&nbsp;&nbsp;&nbsp;Tel: XXX&nbsp;&nbsp;&nbsp;&nbsp;E-mail: XXX@qq.com
			</p>
		</div>
	</div>
	
	
	<script type="text/javascript">
		function getCookie(cookieName) {
    var strCookie = document.cookie;
    var arrCookie = strCookie.split("; ");
    for(var i = 0; i < arrCookie.length; i++){
        var arr = arrCookie[i].split("=");
        if(cookieName == arr[0]){
            return arr[1];
        }
    }
    return "";
}
	
	var userid = getCookie("userid");
	//	alert(userid)
		//alert(sessionStorage.getItem("userid"));
		
		$("#tbb").load("index_head.html");
		
		/**
         * 获取参数的键值对对象。
         * @returns {Object}
         */
        
        function getUrlVars(){    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

//得到指定参数的value
function getUrlVar(name){
    return getUrlVars()[name];
}

		var id = getUrlVar("id");//商品id
		var quantity = getUrlVar("quantity");//商品个数
		var commodity_picture = getUrlVar("commodity_picture");//商品图片
		var commodity_nametop = unescape(getUrlVar("commodity_nametop"));//商品名称
		var shoppricezhekou = getUrlVar("shoppricezhekou");//商品单价
		var leixin = unescape(getUrlVar("leixin"));//商品类型
		var commodity_description = unescape(getUrlVar("commodity_description"));//商品描述

		
		var i = 1;
 if(i===1)
 {
 	showcommodity();
 	i=2;
 }



	function showcommodity () {

            			var tbody = document.getElementById("tbody");
            		
						
							var tr = document.createElement("tr");
							var th = document.createElement("th");
							var a = document.createElement("a");
							var div = document.createElement("div");
							var img = document.createElement("img");
							var td1 = document.createElement("td");
							var div2 = document.createElement("div");
							var input1 = document.createElement("input");
							var input2 = document.createElement("input");
							var div3 = document.createElement("div");
							var td2 = document.createElement("td");
							var td3 = document.createElement("td");
							var td4 = document.createElement("td");
							var td5 = document.createElement("td");
							
							th.scope="row";
							a.href="#";
							div.className="img";
							img.src=commodity_picture;
							img.id="img";
							img.className="cover";
						    div2.className="name ep3";
						    div2.innerHTML=commodity_nametop+" "+commodity_description;
						    input1.name="shopName";
						    input1.id="shopName";
						    input1.value=commodity_nametop;
						    input1.style.display="none";
						    input2.name="orderDesc";
						    input2.id="orderDesc";
						    input2.value=commodity_description;
						    input2.style.display="none";
						    div3.className="type c9";
						    div3.id="attribute";
						    div3.innerHTML=leixin;
						    td2.innerHTML=shoppricezhekou;
						    td2.id="price";
						    td3.innerHTML=quantity;
						    td3.id="number";
						    td3.className="gs";
						    td4.innerHTML="￥0.0";
						    td5.id="zongjia"
							//zj.innerHTML="￥"+getParam().quantity*data.data[i].commodity_price;
							//$("#zj").val(getParam().quantity*data.data[i].commodity_price)
							
							tr.appendChild(th);
							th.appendChild(a);
							a.appendChild(div);
							div.appendChild(img);
							tr.appendChild(td1);
							td1.appendChild(div2);
							td1.appendChild(input1);
							td1.appendChild(input2);
							td1.appendChild(div3);
							tr.appendChild(td2);
							tr.appendChild(td3);
							tr.appendChild(td4);
							tr.appendChild(td5);
							
							tbody.appendChild(tr);
							
							tr.appendChild(th);
							th.appendChild(a);
							a.appendChild(div);
							div.appendChild(img);
							tr.appendChild(td1);
							td1.appendChild(div2);
							td1.appendChild(input1);
							td1.appendChild(input2);
							td1.appendChild(div3);
							tr.appendChild(td2);
							tr.appendChild(td3);
							tr.appendChild(td4);
							tr.appendChild(td5);
							
							tbody.appendChild(tr);
							
						    var price =quantity*shoppricezhekou;
							$("#zongjia").text(price.toFixed(1));
						
	}
	
	$('.btn').click(function() {
		 
		
		//alert(getUrlVar("id"));
		var number = document.getElementById("number").innerHTML;
		var money = number*$('#price').text();
		var price= $('#price').text();
		var img = $("#img").attr("src");
		var description = document.getElementById("orderDesc").value;
		var shopName = document.getElementById("shopName").value;
		var leixin =document.getElementById("attribute").innerHTML;
		
		$.ajax({
					xhrFields:{withCredentials: true},
				    type: "post",//请求方式
				    url: "http://localhost:16111/pay/pay/addshopping",//上s层的路径
					dataType: "json",
				    data:{
				    	user_id:userid,
			commodity_id:getUrlVar("id"),
			commodity_picture:img,
			commodity_nametop:shopName,
			commodity_leixin:leixin,
			commodity_description:description,
			quantity_of_goods:number,
			shopping_Cart_money:money.toFixed(1),
			collection_item_price:price,
				    	},//传值
				    success: function (data)
					{
					//	alert(1);
			var dataObj=eval("("+JSON.stringify(data)+")");
			if (dataObj.code!=0){
			//	alert(dataObj);
				window.location.href="udai_shopcart.html";
			}else{
				//alert(dataObj);
				return;
			}
		           		
					}
					})

		
//		$.post("http://localhost:16800/pay/addshopping",
//		{
//			user_id:1,
//			commodity_id:getUrlVar("id"),
//			commodity_picture:img,
//			commodity_nametop:shopName,
//			commodity_leixin:leixin,
//			commodity_description:description,
//			quantity_of_goods:number,
//			shopping_Cart_money:money.toFixed(1),
//			collection_item_price:price,
//		},
//		function (data){
//			alert(1);
//			var dataObj=eval("("+JSON.stringify(data)+")");
//			if (dataObj.code!=0){
//				alert(dataObj);
//				window.location.href="udai_shopcart.html";
//			}else{
//				alert(dataObj);
//				return;
//			}
//		}
//		)
	})
	</script>
</body>
</html>